/* ****************************************************************************
 *
 * Copyright (c) Microsoft Corporation. 
 *
 * This source code is subject to terms and conditions of the Microsoft Permissive License. A 
 * copy of the license can be found in the License.html file at the root of this distribution. If 
 * you cannot locate the  Microsoft Permissive License, please send an email to 
 * ironpy@microsoft.com. By using this source code in any fashion, you are agreeing to be bound 
 * by the terms of the Microsoft Permissive License.
 *
 * You must not remove this notice, or any other, from this software.
 *
 *
 * ***************************************************************************/

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Threading;

using Microsoft.Scripting;
using Microsoft.Scripting.Internal.Generation;
using Microsoft.Scripting.Internal.Ast;
using Microsoft.Scripting.Hosting;
using Nua;
using Nua.Hosting;
using Nua.Compiler;

namespace Nua.Runtime 
{
    public sealed class NuaContext : LanguageContext 
    {
        static NuaContext _context;
        bool _showCls = true;

        public NuaContext(ScriptEngine engine) : base(engine)
        {
            _context = this;
            
        }

        public static CodeContext CreateDefaultContext(ScriptEngine engine)
        {
            ScriptModule globalMod = ScriptDomainManager.CurrentManager.CreateModule("global", new Scope(new SymbolDictionary()));
            return new CodeContext(globalMod.Scope, new NuaContext(engine));

        }

        public override object CallWithKeywordArgs(CodeContext context, object func, object[] args, string[] names)
        {
            if (func is string)
            {
                if (((string)func) == "print")
                    foreach (object o in args)
                    Console.Write(o);
            }

            return null;
            
        }
     

        public static ContextId Context = ContextId.RegisterContext(typeof(NuaContext));

        public override ContextId ContextId
        {
            get
            {
                return Context;
            }
        }

        

        public override object GetMember(CodeContext context, object target, SymbolId name) 
        {
            //return Ops.GetAttr(context, target, name);
            return new object();
        }


        public override bool ShowCls
        {
            get
            {
                return _showCls;
            }
            set
            {
                _showCls = value;
            }
        }
    }   
}
